
const requsts = require("/util/requst");
const util = require("/util/util");
Page({
  data: {
    top: 0,
    banner:[],
    showBanner:false,
    prolistshiw:false,
    rentrue:false,
    indicatorDots: true,
    autoplay: true,
    vertical: false,
    interval: 1000,
    circular: false,
    params:"",
    indicatorcolor:"#fff",
    indicatoractive:"#FF5000",
    lazyload:true,
    list5:[],
    defaultsource:"https://gw.alipayobjects.com/zos/rmsportal/VBqNBOiGYkCjqocXjdUj.png",
    list3: [],
    list4:[]
  },
  intenfn(e){
    console.log(e)
      my.navigateTo({
        url: '../../common/goodsdetial/goodsdetial?productType='+e.currentTarget.dataset.productType+"&id="+e.currentTarget.dataset.id,
    })
  },
   intennewfn(ev) {
    // my.alert({
    //   content: ev.currentTarget.dataset.item,
    // });
  },
  bannerfn(){
    
    var that=this
      my.request({
        url: requsts.url+"/product/getBanner",
        method: 'POST',
        dataType: 'json',
        success: function(res) {
         if(res.data.code!=0){
              util.toastfn(res.data.msg)
              return
          }
         var arr=[]
         for(var i = 0; i<res.data.data.length;i++){
            arr.push((res.data.data)[i].imageUrl)
            
         }
         that.setData({
            banner:arr,
            showBanner:true
          })
        },
        fail: function(res) {
          util.toastfn(res.errorMessage)
        },
      });
  },
  Productlist(){
      var that=this
      my.request({
        url: requsts.url+"/product/getProductTypeConfigList",
        method: 'POST',
        dataType: 'json',
        success: function(res) {
         console.log(res.data.data)
         if(res.data.code!=0){
              util.toastfn(res.data.msg)
              return
          }
         that.setData({
            list3:res.data.data,
            prolistshiw:true
          })
        },
        fail: function(res) {
          util.toastfn(res.errorMessage)
        },
      });
  },
  onReady() {
     console.log("onReady")
  //   // 页面加载完成
    console.log(this.data.prolistshiw)
    console.log(this.data.showBanner)
    console.log(this.data.rentrue)
   if(this.data.prolistshiw==true&&this.data.showBanner==true&&this.data.rentrue==true){
        my.hideLoading();
    }
  },
  renmenfn(){
    var that=this
      my.request({
        url: requsts.url+"/product/getProductInfo",
        method: 'POST',
        dataType: 'json',
        success: function(res) {
          if(res.data.code!=0){
              util.toastfn(res.data.msg)
              return
          }
         that.setData({
            list5:res.data.data.hostProductList,
            rentrue:true
          })
          console.log(that.data.list5)
        },
        fail: function(res) {
          util.toastfn(res.errorMessage)
        },
      });
  },
  onLoad() {
    this.bannerfn()
    this.Productlist() //类型列表
    this.renmenfn()
    // 页面加载
    // my.showLoading({
    //   content: '加载中...',
    // });
  },
  naurl(e){
    my.navigateTo({
        url:'/page/common/goodsorder/goodsorder?productType='+e.currentTarget.dataset.id,
    })
  }
});
